#!/bin/sh
PREREQ=""
prereqs() {
    echo "$PREREQ"
}
case "$1" in
    prereqs)
        prereqs
        exit 0
        ;;
esac

. /usr/share/initramfs-tools/hook-functions

# 复制 veritysetup 和 cryptsetup 到 initramfs
copy_exec /usr/sbin/veritysetup /sbin
copy_exec /usr/sbin/cryptsetup /sbin

copy_exec /usr/sbin/dmsetup /sbin
# 复制依赖库（根据实际路径调整）
[ -f /usr/lib/x86_64-linux-gnu/libcryptsetup.so.12 ] && \
    copy_exec /usr/lib/x86_64-linux-gnu/libcryptsetup.so.12 /usr/lib

# 手动复制 generator
[ -x /usr/lib/systemd/system-generators/systemd-veritysetup-generator ] && \
    mkdir -p ${DESTDIR}/usr/lib/systemd/system-generators && \
    cp /usr/lib/systemd/system-generators/systemd-veritysetup-generator ${DESTDIR}/usr/lib/systemd/system-generators/
copy_exec /usr/lib/x86_64-linux-gnu/systemd/libsystemd-shared-256.so

copy_exec /usr/bin/systemd-escape /usr/bin


copy_exec /usr/lib/systemd/system/veritysetup.target

# 添加 dm-verity 内核模块
manual_add_modules dm_verity